package com.kuanter.kuanterauto.entity;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import com.kuanter.kuanterauto.utils.StringUtils;


/** 
 * @author utopia
 * @version 2013-10-21 下午3:47:43
 * 
 */
public class Restriction {

	private String tailNum;
	private String dRRegion;
	private String dTime;
	public String getTailNum() {
		return tailNum;
	}
	public void setTailNum(String tailNum) {
		this.tailNum = tailNum;
	}
	public String getdRRegion() {
		return dRRegion;
	}
	public void setdRRegion(String dRRegion) {
		this.dRRegion = dRRegion;
	}
	public String getdTime() {
		return dTime;
	}
	public void setdTime(String dTime) {
		this.dTime = dTime;
	}
	
	public static List<Restriction> getRestrictionsList(String json) {
		List<Restriction> list = null;
		if(json != null) {
			try {
				JSONObject jo = new JSONObject(json);
				if(StringUtils.isSuccess(json)) {
					JSONArray ja = jo.optJSONArray("DRList");
					if(ja != null) {
						list = new ArrayList<Restriction>();
						for(int i = 0; i < ja.length(); i++) {
							Restriction res = new Restriction();
							JSONObject jo_res = ja.optJSONObject(i);
							res.setdRRegion(jo_res.optString("DRRegion"));
							res.setdTime(jo_res.optString("DRTime"));
							res.setTailNum(jo_res.optString("tailNums"));
							list.add(res);
						}
					}
				}
			} catch (JSONException e) {
				e.printStackTrace();
			}
		}
		return list;
	}
}
